<html xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <title>系统设置</title>
    <script src="/static/statics/libs/jquery-1.7.2.js"></script>
    <link rel="stylesheet" href="/static/statics/css/font-awesome.min.css">
    <link rel="stylesheet" href="/static/statics/plugins/layui/css/layui.css" media="all">
    <script src="/static/statics/plugins/layer/layer.js"></script>
    <script src="/static/statics/plugins/layui/layui.js"></script>
    <script src="/static/statics/plugins/ztree/jquery.ztree.all.min.js"></script>
    <link rel="stylesheet" href="/static/statics/plugins/ztree/css/metroStyle/metroStyle.css">
    <link rel="stylesheet" href="/static/common/css/cyStyle.css">
    <link rel="stylesheet" href="/static/common/css/cyType.css">
    <script src="/static/common/js/whole/cyLayer.js"></script>
    <script src="/static/common/js/whole/common.js"></script>
    <script src="/static/common/js/selectTool.js"></script>
    <style>
    </style>
</head>
<body>

<div class="menus" style="margin:5px;">
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-form-item">
            <label class="layui-form-label" pane>数据源</label>
            <div class="layui-input-block">
                <select name="initDbsource" id="initDbsource">
                <option value="1" selected>项目启动时主动初始化数据源</option>
                <option value="2" >手动初始化数据源</option>
            </select>
                <input type="hidden" name="ids" th:value="${obj.id}">
                <input type="hidden" id="initDbsourceVal" th:value="${obj.initDbsource}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" pane>日志记录</label>
            <div class="layui-input-block">
                <select name="col3" id="col3" >
                <option value="1" selected>记录SQL执行日志</option>
                <option value="2" >不记录SQL执行日志</option>
            </select>
                <input type="hidden" id="col3Val" th:value="${obj.col3}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" pane>清空日志</label>
            <div class="layui-input-block">
                <button class="layui-btn layui-btn-danger" onclick="deleteOne('清除SQL执行日志','dbSource/sqlController/delLog/1');return false;" >清空SQL执行记录</button>
                <button class="layui-btn layui-btn-danger" onclick="deleteOne('清除用户登陆日志','dbSource/sqlController/delLog/2','1');return false;" >清空登陆系统记录</button>
                <button class="layui-btn layui-btn-danger" onclick="deleteOne('清除作业日志','timing/jobLogDelete','1');return false;" >清空作业执行记录</button>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <button class="layui-btn" id="suBtn">立即保存</button>
            </div>
        </div>
    </form>
</div>
<script>
    layui.use(['form','table','element'], function(){
         form = layui.form;
         table = layui.table;
         element = layui.element;
        var form = layui.form;


        $("#initDbsource").each(function() {
            $(this).children("option").each(function() {
                if (this.value == $("#initDbsourceVal").val()) {
                    $(this).attr("selected","selected");
                }
            });
        });
        $("#col3").each(function() {
            $(this).children("option").each(function() {
                if (this.value == $("#col3Val").val()) {
                    $(this).attr("selected","selected");
                }
            });
        });
        form.render();

        $("#suBtn").click(function(){
            var url = "sysConroller/updateSysSetUp";
            var params= {'initDbsource':$("#initDbsource").val(),'col3':$("#col3").val(),'id':1};
            var indexOpen =  Loading.open(2,true);
            $.ajax({
                type:'POST',
                url:url,
                data:params,
                dataType:"json",
                success:function(data){
                    Loading.close(indexOpen);
                    if(data.code==1){
                        layer.msg("修改成功！", {icon: 1});
                    }else{
                        layer.msg(data.msg, {icon: 2});
                    }
                },
                error:function (data) {
                    Loading.close(indexOpen);
                    Msg.error("执行异常!");
                }
            });
           return false;
        });
    });
    </script>
</body>
</html>